﻿namespace Viyi.Util.NameStyle
{
    internal sealed class UnderscoreStyleConverter : IStyleConverter
    {
        public string Convert(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return name;
            }

            return Contants.UpperRegex.Replace(
                Contants.LowerRegex.IsMatch(name) ? name : name.ToLower(),
                m => "_" + m.Value
            ).Replace('-', '_').ToLower();
        }
    }
}